const mysql = require('mysql');

function createConnection() {
	return mysql.createConnection({
		host: 'localhost',
		user: 'root',
		password: '1040165115',
		database: 'tz8Vocaloid',
		timezone: 'Asia/Shanghai',
		multipleStatements: true
	})
}

exports.base = (sql) => {
	return new Promise((resolve, reject) => {
		let connection = createConnection();
		connection.connect();
		connection.query(sql, function(error, results, fields) {
			if (error) {
				reject(error);
			}
			resolve(results);
		})
		connection.end();
	})
}
